public class Text {
    public ListNode removeElements(ListNode head, int val) {
        if(head == null) {
            return null;
        }
        ListNode cur = head;
        while(cur != null) {
            ListNode curnext=cur.next;
            while( (curnext != null)&&(curnext.val == val)){
                curnext=curnext.next;
                if(curnext == null) {
                    cur.next=null;
                    break;
                }
            }
            cur.next=curnext;
            cur=curnext;
        }
        if(head.val == val){
            return head.next;
        }
        return head;
    }
    public int removeDuplicates(int[] nums) {
        int drc=0;
        int cur=0;
        while(cur<nums.length) {
            if(nums[drc]==nums[cur]) {
                cur++;
            }else {
                nums[drc+1]=nums[cur];
                drc++;
                cur++;
            }
        }
        return drc+1;
    }
    public static void main(String[] args) {
        int[] nums1={4,6,8,0,0,0};
        int[] nums2={1,5,9};
    }
    public static void merge(int[] nums1, int m, int[] nums2, int n) {
        int k = m+n-1;
        int i = m-1;
        int j = n-1;
        while(i>=0 && j>=0) {
            if(nums1[i]>nums2[j]){
                nums1[k]=nums1[i];
                i--;
                k--;
            }else {
                nums1[k]=nums2[j];
                j--;
                k--;
            }
        }
        while(j>=0){
            nums1[k]=nums2[j];
            j--;
            k--;
        }
    }
}
